package com.zr.sms.serviceimpl;


import com.zr.sms.dao.GoodsDao;
import com.zr.sms.dao.S_gDao;
import com.zr.sms.daoimpl.GoodsDaoimpl;
import com.zr.sms.daoimpl.S_gDaoimpl;
import com.zr.sms.model.Goods;
import com.zr.sms.service.Goodsinfomanageservice;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**
 * 服务层的实现
 * @author 吴浩
 *
 */
public class Goodsinfomanageserviceimpl implements Goodsinfomanageservice{
	
GoodsDao gimdao=new  GoodsDaoimpl();
S_gDao s_gdao=new S_gDaoimpl();
	
	public JSONObject getGoods(int start, int pagesize) {
		// TODO Auto-generated method stub
		JSONObject goods=new JSONObject();
		goods.put("total", JSONArray.fromObject(gimdao.getgoodscount()));
		goods.put("rows", JSONArray.fromObject(gimdao.getGoods(start, pagesize)));
		return goods;
	}

	
	public boolean insertgoods(Goods g) {
		// TODO Auto-generated method stub
		
		return gimdao.insertgoods(g);
	}

	
	public boolean updategoods(Goods g) {
		// TODO Auto-generated method stub
		return gimdao.updategoods(g);
	}

	
	public boolean deletegoods(String[] gids) {
		// TODO Auto-generated method stub
		return gimdao.deletegoods(gids);
	}


	public JSONObject getGoods(int start, int pagesize, String searchname) {
		// TODO Auto-generated method stub
		JSONObject goods=new JSONObject();
		goods.put("total", JSONArray.fromObject(gimdao.getgoodscount()));
		goods.put("rows", JSONArray.fromObject(gimdao.getGoods(start, pagesize,searchname)));
		return goods;
	}


	public boolean deletes_g(String[] gids) {
		// TODO Auto-generated method stub
		return s_gdao.deletes_g(gids);
	}

	
	public int selectMaxGid() {
		
		return gimdao.selectMaxGid();
	}

}
